import parse from '@dfeidao/atom-web/dt/parse';
import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import set from '@dfeidao/atom-web/local/set';
import error from '@dfeidao/atom-web/msgbox/error';
import a001 from './a001';
export default async function a002(fd: IFeidaoAiBrowserComponent) {
	// todo
	// 查询
	const f = {} as { operation_time: {}; resume_name: {}; op_cont: {} };
	const start_time1 = fd.data.node.querySelector<HTMLInputElement>('[start_time]').value;
	const end_time1 = fd.data.node.querySelector<HTMLInputElement>('[end_time]').value;
	const start_time = parse(start_time1) - 28800000;
	const end_time = parse(end_time1) + 57599999;
	set(fd, 'start_time', start_time1);
	set(fd, 'end_time', end_time1);
	if (start_time > end_time) {
		error('开始时间不能大于结束时间');
		return;
	}
	if (start_time) {
		f.operation_time = { $gt: start_time, $lt: new Date().getTime() };
	}
	if (end_time) {
		f.operation_time = { $gt: 0, $lt: end_time };
	}
	if (start_time && end_time) {
		f.operation_time = { $gt: start_time, $lt: end_time };
	}

	const resume_name = fd.data.node.querySelector<HTMLInputElement>('[resume_name]').value;
	f.resume_name = { $like: '%' + resume_name + '%' };

	const op_cont = fd.data.node.querySelector<HTMLInputElement>('[op_cont]').value;

	f.op_cont = { $like: '%' + op_cont + '%' };
	set(fd, 'f', f);
	set(fd, 'page_no', 1);
	await a001(fd);
}
